//节流
export const debounce = (fn, delay) => {
	let timer = null;
	return function() {
		let context = this;
		let args = arguments;
		clearTimeout(timer);
		timer = setTimeout(function() {
			fn.apply(context, args);
		}, delay);
	};
};
//封装防抖
export const throttle = (fn, delay) => {
	let valid = true;
	return function() {
		let context = this;
		let args = arguments;
		if (!valid) {
			return false;
		}
		valid = false;
		setTimeout(() => {
			//console.log('coming');
			//fn();
			fn.apply(context, args);
			valid = true;
		}, delay);
	};
};